{include file="public/head"/} 
<style>
  #click{
    width:100%;
    height:100%;
    background-color: rgba(0,0,0,0.5);
    position:fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    display: none;

  }
</style>
  <body>
    <div id="click" onclick="aa()" ></div>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">人员信息管理中心</a>
        <a><cite>人员管理</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="javascript:location.reload()" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
          <form class="layui-form layui-col-md12 x-so"  method="get" action="#">
            <div class="layui-input-inline">
            <select name="community_id" lay-filter="community_id" id="community_id">
              <option value="">所属小区</option>
              {foreach $communitylist as $name}
              <option value="{$name.id}" {if isset($community_id)}{if $community_id == $name.id}selected{/if}{/if}>{$name.name}</option>
              {/foreach}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="group" id="group" lay-filter="group">
              <option value="">组团</option>
              {if isset($groups)}
              {foreach $groups as $gro}
                <option value="{$gro}" {if isset($group)}{if $gro == $group}selected{/if}{/if}>{$gro}</option>
              {/foreach}
              {/if}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="building" id="building" lay-filter="building">
              <option value="">所属楼栋</option>
              {if isset($buildings)}
              {foreach $buildings as $build}
                <option value="{$build}" {if isset($building)}{if $build == $building}selected{/if}{/if}>{$build}幢</option>
              {/foreach}
              {/if}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="unit" id="unit"  lay-filter="unit">
              <option value="">所属单元</option>
              {if isset($units)}
              {foreach $units as $uni}
                <option value="{$uni}" {if isset($unit)}{if $uni == $unit}selected{/if}{/if}>{$uni}单元</option>
              {/foreach}
              {/if}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="room" id="room">
              <option value="">所属房间号</option>
              {if isset($rooms)}
              {foreach $rooms as $roo}
                <option value="{$roo}" {if isset($room)}{if $roo == $room}selected{/if}{/if}>{$roo}室</option>
              {/foreach}
              {/if}
            </select>
          </div>
            <input class="layui-input" placeholder="手机号" name="phone" value="{if isset($phone)}{$phone}{/if}">
            
             <input class="layui-input" placeholder="姓名" name="owner_name" value="{if isset($owner_name)}{$owner_name}{/if}">
            
            
            
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
          </form>
      </div>
      <xblock>
      <button class="layui-btn " onclick="x_admin_show('家属添加','{:url('familyadd')}',600,600)"><i class="layui-icon"></i>家属添加</button>
        <span class="x-right" style="line-height:40px">共有数据：{$number} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>小区</th>
            <th>房号</th>
            <th>关系</th>
            <th>姓名</th>
            <th>手机号</th>
            

            <th>时间</th>

            <td>图片</td>
            <th>操作</th> 
          </tr>
        </thead>
        <tbody>
          {foreach $list as $lis}
          <tr style="height:80px">
            <td>{$lis.community_name}</td>
            <td>{$lis.building}-{$lis.unit}-{$lis.room}</td>
            <td>
              {if $lis.relation == 0}
              业主
              {elseif $lis.relation == 1}
              家属
              {elseif $lis.relation == 2}
              租户
              {elseif $lis.relation == 3}
              访客
              {elseif $lis.relation == 4}
              企业员工
              {elseif $lis.relation == 5}
              物业员工
              {/if}
            </td>
            <td>{$lis.name}</td>
            <td>{$lis.phone}</td>
            
           

            <td>{$lis.ctime}</td>


            <td style="width:15%">
             
              {volist name="$lis.pic" id="pic"}
              <img src="{$pic['faceUrl']}" onclick='mag("{$pic.faceUrl}")' style="width:60px;height:60px">
              {/volist}
              &nbsp;&nbsp;&nbsp;&nbsp;
              {if $lis.picnum != "3"}
              <button type="button" class="layui-btn-zaozao" onclick="cam('{$lis.id}')" style="background-color: #0066ff">拍照</button>
              <button type="button" class="layui-btn-zaozao" onclick="x_admin_show('上传照片','{:url(\'uploadimage\')}?id={$lis.id}',600,600)" style="background-color: #0066ff">上传照片</button>
              {/if}
            </td>
            <td class="td-manage" style="width:25%">

              {if $lis.personGuid !== "0"}
              <button type="button" class="layui-btn-zaozao" onclick="x_admin_show('设备授权','{:url(\'deviceaccredit\')}?id={$lis.id}','700')" style="background-color: #42b8f1">授权</button>

              {/if}
              <button type="button" class="layui-btn-zaozao" onclick="personnelEdit('{$lis.id}')" style="background-color: #34f1d4">编辑</button>

              <button type="button" class="layui-btn-zaozao" onclick="idcardEdit('{$lis.id}')" style="background-color: #52f15b">身份证修改</button>

              <button type="button" class="layui-btn-zaozao" onclick="ufacedel('{$lis.id}')" style="background-color: #fd5f56">删除</button>
             
            </td> 
          </tr>
          {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div>
            {$personnellist->render()}
        </div>
      </div>

    </div>
    
    <script>
        function cam(id){
            var url = "{:url('cam')}?&id=" + id;
            layer.open({
                type: 2,
                title: '拍照',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                content: url //iframe的url
            });
        } 
        function personnelEdit(id){
            var url = "{:url('personnelEdit')}?id=" + id;
            layer.open({
                type: 2,
                title: '人员编辑',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                content: url //iframe的url
            });
        }
        
        function idcardEdit(id){
            var url = "{:url('idcardEdit')}?id=" + id;
            layer.open({
                type: 2,
                title: '健康码修改',
                shadeClose: true,
                shade: 0.8,
                area: ['60%', '60%'],
                content: url //iframe的url
            });
        }
    </script>
  <script>
      let a = document.getElementById("click")
      function mag(url){
          // console.log(123)

          a.style = "display:inline-block;"
          let b = `<img src="`+url+`" style="margin-left:20%;text-align:center">`
          a.innerHTML=b
      }
      function aa() {
          a.style = "display:none;"
      }

    //删除
    function ufacedel(id, doc){
      if(confirm('确定要删除吗?')) 
      { 
        var url = "{:url('ufacedel')}?id=" + id
         window.location.href=url
        // console.log(url)
        //$('#' + doc).attr('href', url)
      } 
        return false; 
    }   
    function ufaceEdit(id){
      
      var url = "{:url('ufaceEdit')}?id=" + id
      window.location.href=url
      
    }
  </script>
    <script>
        layui.use(['form'], function() {
            var form = layui.form
            form.on('select(community_id)', function(f){
                var url = "{:url('room/fetchdata')}"
                $.post(url, {community_id: f.value, type: 1}, function(data) {
                    $('#group').html("")
                    var option = "<option value=''>所有组团</option>"
                    $('#group').append(option)
                    for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                    $('#group').append(option)
                    }
                    
                    form.render('select')
                })
                
                $('#community_id').data('community_id', f.value)
            })

            form.on('select(group)', function(f){
                var data_community = $('#community_id').data('community_id')
                var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
                var community_id = typeof data_community === 'undefined' ? get_community : data_community
                var url = "{:url('room/fetchdata')}"
                $.post(url, {community_id: community_id, group: f.value, type: 2}, function(data) {
                    $('#building').html("")
                    var option = "<option value=''>所有楼栋</option>"
                    $('#building').append(option)
                    for (var i = 0; i < data.length; i++) {
                        option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                        $('#building').append(option)
                    }
                    $('#group').data('group', f.value)
                    form.render('select')
                })
            })
    
            form.on('select(building)', function(f){
                var data_community = $('#community_id').data('community_id')
                var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
                var community_id = typeof data_community === 'undefined' ? get_community : data_community

                var data_group = $('#group').data('group')
                var get_group = "<?php if (isset($group)) { echo $group;}?>"
                var group = typeof data_group === 'undefined' ? get_group : data_group

                var url = "{:url('room/fetchdata')}"
                $.post(url, {building: f.value, community_id: community_id, group: group, type: 3}, function(data) {
                $('#unit').html("")
                var option = "<option value=''>所有单元</option>"
                $('#unit').append(option)
                for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                    $('#unit').append(option)
                }
                $('#building').data('building', f.value)
                form.render('select')
                })
            })
    
            form.on('select(unit)', function(f){
                var data_community = $('#community_id').data('community_id')
                var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
                var community_id = typeof data_community === 'undefined' ? get_community : data_community

                var data_group = $('#group').data('group')
                var get_group = "<?php if (isset($group)) { echo $group;}?>"
                var group = typeof data_group === 'undefined' ? get_group : data_group

                var data_building = $('#building').data('building')
                var get_building = "<?php if (isset($building)) { echo $building;}?>"
                var building = typeof data_building === 'undefined' ? get_building : data_building
        
                var url = "{:url('room/fetchdata')}"
                $.post(url, {unit: f.value, community_id: community_id, group: group, building: building, type: 4}, function(data) {
                $('#room').html("")
                var option = "<option value=''>所有房间</option>"
                $('#room').append(option)
                for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                    $('#room').append(option)
                }
                $('#unit').data('unit', f.value)
                form.render('select')
                })
            })
    
        })
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
  </body>

</html>